/**
 * 
 */
package edu.wpi.cs509.messages.server;

import edu.wpi.cs509.messages.MsgBc;
import edu.wpi.cs509.messages.client.MsgLeaderBrdReply;


/**
 * This class implements the get-leaderboard message, based
 * on rank/count.
 * @author sparadis
 *
 */
public class MsgGetLeaderBrdRank extends MsgServerContext {

	/**
	 * serializable version number
	 */
	private static final long serialVersionUID = 1L;
	
	/**
	 * rank and count to filter leaderboard by
	 */
	protected int rank;
	protected int count;
	
	/**
	 * Constructor.
	 * @param rank - rank used by leaderboard filtering
	 * @param count - count used by leaderboard filtering
	 */
	public MsgGetLeaderBrdRank(int rank, int count) {
		this.rank = rank;
		this.count = count;
	}

	/**
	 * Get the leaderbrd.
	 * @return MsgBc - the reply msg with the leaderbrd contents
	 */
	public MsgBc doExecuteAndGetReply() {
		//Get the leaderboard by rank/count, return it in the reply msg.
		return (new MsgLeaderBrdReply(
				getServer().getLeaderBoard(rank, count, this.getConnection()), rank));
	}
}
